/*
 * @lc app=leetcode.cn id=70 lang=cpp
 *
 * [70] 爬楼梯
 *
 * 方法1：动态规划
 * - dp[i] = dp[i-1] + dp[i-2]
 * - 不需要 dp[i] 存储也行
 */

#include <vector>

// @lc code=start
class Solution
{
public:
    int climbStairs(int n)
    {
        int i_0 = 0, i_1 = 0, i_2 = 1;
        /* dp[i] = dp[i-1] + dp[i-2] */
        for (int i = 0; i < n; i++)
        {
            i_0 = i_1;
            i_1 = i_2;
            i_2 = i_0 + i_1;
        }

        return i_2;
    }
};
// @lc code=end
